package tool.gzzz.web.service.impl;

import tool.gzzz.util.SM4Util_Str;
import tool.gzzz.util.Sm4Util;
import tool.gzzz.web.domain.request.Sm4Request;
import tool.gzzz.web.domain.response.Sm4Response;
import tool.gzzz.web.service.Sm4Service;

/**
 * @author gz
 */
public class Sm4ServiceImpl implements Sm4Service {

  @Override
  public Sm4Response encrypt(Sm4Request request) throws Exception {
    return Sm4Util.encrypt(request);
  }

  @Override
  public Sm4Response decrypt(Sm4Request request) throws Exception {
    return Sm4Util.decrypt(request);
  }

  public static void main(String[] args) {
    SM4Util_Str sm4UtilStr = new SM4Util_Str();
    String context = "80b3418c486ca6bd9fd8c14b5fd640efa3be4832ad8647f81a9486bb10c1adcc81b3b3958d1fe03fc5ee8b5651993b56";
    try {
      System.out.println("解密 = " + sm4UtilStr.decryptM4(context));
    } catch (Exception e) {
      System.err.println("解密失败");
    }
    try {
      System.out.println("加密 = " + sm4UtilStr.encryptSM4(context));
    } catch (Exception e) {
      System.err.println("加密失败");
    }
  }

}
